/*
 *  Copyright (C) void Team 2010 Pedro Batista
 * 
 *  http://code.google.com/p/capacitec
 * 
 *  This file is part of capacitec.
 * 
 *  capacitec is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  capacitec is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with capacitec.  If not, see <http://www.gnu.org/licenses/>.
 */

package entidades;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author pedro
 */
@Entity
@Table(name = "aluno_subprograma_turma")
@NamedQueries({
	@NamedQuery(name = "AlunoSubProgramaTurma.findAll", query = "SELECT a FROM AlunoSubProgramaTurma a"),
	@NamedQuery(name = "AlunoSubProgramaTurma.findByAlunoSubprogramaAlunoPessoaId", query = "SELECT a FROM AlunoSubProgramaTurma a WHERE a.alunoSubProgramaTurmaPK.alunoSubprogramaAlunoPessoaId = :alunoSubprogramaAlunoPessoaId"),
	@NamedQuery(name = "AlunoSubProgramaTurma.findByAlunosubprogramasubProgramaid", query = "SELECT a FROM AlunoSubProgramaTurma a WHERE a.alunoSubProgramaTurmaPK.alunosubprogramasubProgramaid = :alunosubprogramasubProgramaid"),
	@NamedQuery(name = "AlunoSubProgramaTurma.findByCursoId", query = "SELECT a FROM AlunoSubProgramaTurma a WHERE a.alunoSubProgramaTurmaPK.cursoId = :cursoId")})
public class AlunoSubProgramaTurma implements Serializable {
	private static final long serialVersionUID = 1L;
	@EmbeddedId
	protected AlunoSubProgramaTurmaPK alunoSubProgramaTurmaPK;
	@JoinColumn(name = "curso_id", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
        @ManyToOne(optional = false)
	private Curso curso;
	@JoinColumn(name = "turma_id", referencedColumnName = "id", nullable = false)
        @ManyToOne(optional = false)
	private Turma turma;
	@JoinColumns({
        	@JoinColumn(name = "aluno_subprograma_aluno_pessoa_id", referencedColumnName = "aluno_pessoa_id", nullable = false, insertable = false, updatable = false),
        	@JoinColumn(name = "aluno_subprograma_subPrograma_id", referencedColumnName = "subPrograma_id", nullable = false, insertable = false, updatable = false)})
        @ManyToOne(optional = false)
	private AlunoSubPrograma alunoSubPrograma;

	public AlunoSubProgramaTurma() {
	}

	public AlunoSubProgramaTurma(AlunoSubProgramaTurmaPK alunoSubProgramaTurmaPK) {
		this.alunoSubProgramaTurmaPK = alunoSubProgramaTurmaPK;
	}

	public AlunoSubProgramaTurma(int alunoSubprogramaAlunoPessoaId, int alunosubprogramasubProgramaid, int cursoId) {
		this.alunoSubProgramaTurmaPK = new AlunoSubProgramaTurmaPK(alunoSubprogramaAlunoPessoaId, alunosubprogramasubProgramaid, cursoId);
	}

	public AlunoSubProgramaTurmaPK getAlunoSubProgramaTurmaPK() {
		return alunoSubProgramaTurmaPK;
	}

	public void setAlunoSubProgramaTurmaPK(AlunoSubProgramaTurmaPK alunoSubProgramaTurmaPK) {
		this.alunoSubProgramaTurmaPK = alunoSubProgramaTurmaPK;
	}

	public Curso getCurso() {
		return curso;
	}

	public void setCurso(Curso curso) {
		this.curso = curso;
	}

	public Turma getTurma() {
		return turma;
	}

	public void setTurma(Turma turma) {
		this.turma = turma;
	}

	public AlunoSubPrograma getAlunoSubPrograma() {
		return alunoSubPrograma;
	}

	public void setAlunoSubPrograma(AlunoSubPrograma alunoSubPrograma) {
		this.alunoSubPrograma = alunoSubPrograma;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (alunoSubProgramaTurmaPK != null ? alunoSubProgramaTurmaPK.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof AlunoSubProgramaTurma)) {
			return false;
		}
		AlunoSubProgramaTurma other = (AlunoSubProgramaTurma) object;
		if ((this.alunoSubProgramaTurmaPK == null && other.alunoSubProgramaTurmaPK != null) || (this.alunoSubProgramaTurmaPK != null && !this.alunoSubProgramaTurmaPK.equals(other.alunoSubProgramaTurmaPK))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "entidades.AlunoSubProgramaTurma[alunoSubProgramaTurmaPK=" + alunoSubProgramaTurmaPK + "]";
	}

}
